package com.j180.dao.impl;

import com.j180.bean.StudentBean;
import com.j180.dao.IStudentDao;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class StudentDaoImpl implements IStudentDao {
    @Override
    public void insertStudent(StudentBean student) {


        System.out.println("添加一个学生"+student);
/*
        try {
            Thread.sleep((long) (Math.random()*20*1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/

    }

    @Override
    public List<StudentBean> getStudents() {

        System.out.println("查询所有的学生信息");

        List<StudentBean> list = new ArrayList<>();
        list.add(new StudentBean(1,"小张"));
        list.add(new StudentBean(2,"小李"));
/*
        try {
            Thread.sleep((long) (Math.random()*20*1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/

      //  int num = 10/0;

        return list;
    }

    @Override
    public StudentBean getStudentById(int id) {


        System.out.println("查询id="+id+"的学生信息");

       /* try {
            Thread.sleep((long) (Math.random()*20*1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/

        return new StudentBean(id,"某某某");

    }

    @Override
    public int updateStudent(StudentBean studentBean) {

        System.out.println("更新学生信息");

       /* try {
            Thread.sleep((long) (Math.random()*20*1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/

        return 0;
    }

    @Override
    public int deleteStudentById(int studentId) {


        System.out.println("删除id="+studentId+"的学生信息");

       /* try {
            Thread.sleep((long) (Math.random()*20*1000));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/

        return 0;
    }
}
